package com.ht.shortlink.project.controller;

import com.ht.shortlink.project.common.convention.result.Result;
import com.ht.shortlink.project.common.convention.result.Results;
import com.ht.shortlink.project.service.IUrlTitleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class UrlTitleController {
    private final IUrlTitleService urlTitleService;

    @GetMapping("/api/short-link/v1/title")
    private Result<String> getTitle(@RequestParam("url") String url){
        return Results.success(urlTitleService.getTitle(url));
    }
}
